﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Player : MonoBehaviour
{
    public Image hpImage;
    public int hp = 100;
    [HideInInspector]
    public int curHP = 100;
    public int id;
    public Transform body;

    private void Start()
    {
        curHP = hp;
    }

    public void PlayAnim(string name)
    {
        for (int i = 0; i < body.childCount; i++)
        {
            if (body.GetChild(i).transform.name == name)
            {
                body.GetChild(i).gameObject.SetActive(true);
            }
            else
            {
                body.GetChild(i).gameObject.SetActive(false);
            }
        }
    }

    public void TakeDamage(int value)
    {
        curHP -= 20;
        hpImage.fillAmount = (float)curHP / hp;
    }
}
